<?php
// +----------------------------------------------------------------------
// | author: admin
// +----------------------------------------------------------------------


namespace app\adminapi\controller\travel;


use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\travel\LinePriceLists;
use app\adminapi\logic\travel\LinePriceLogic;
use app\adminapi\validate\travel\LinePriceValidate;
use app\common\model\user\User;


/**
 * LinePrice控制器
 * Class LinePriceController
 * @package app\adminapi\controller\travel
 */
class LinePriceController extends BaseAdminController
{


    /**
     * @notes 获取列表
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/29 09:56
     */
    public function lists()
    {
        return $this->dataLists(new LinePriceLists());
    }


    /**
     * @notes 添加
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/29 09:56
     */
    public function add()
    {
        $params = (new LinePriceValidate())->post()->goCheck('add');
        $params['user_id'] = User::where('account', $this->adminInfo['account'])->value('id');
        $result = LinePriceLogic::add($params);
        if (true === $result) {
            return $this->success('添加成功', [], 1, 1);
        }
        return $this->fail(LinePriceLogic::getError());
    }


    /**
     * @notes 编辑
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/29 09:56
     */
    public function edit()
    {
        $params = (new LinePriceValidate())->post()->goCheck('edit');
        $result = LinePriceLogic::edit($params);
        if (true === $result) {
            return $this->success('编辑成功', [], 1, 1);
        }
        return $this->fail(LinePriceLogic::getError());
    }


    /**
     * @notes 删除
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/29 09:56
     */
    public function delete()
    {
        $params = (new LinePriceValidate())->post()->goCheck('delete');
        LinePriceLogic::delete($params);
        return $this->success('删除成功', [], 1, 1);
    }


    /**
     * @notes 获取详情
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/29 09:56
     */
    public function detail()
    {
        $params = (new LinePriceValidate())->goCheck('detail');
        $result = LinePriceLogic::detail($params);
        return $this->data($result);
    }

    /**
     * @notes  更改状态
     * @return \think\response\Json
     * @author admin
     * @date 2025/04/23 18:23
     */
    public function updateStatus()
    {
        $params = (new LinePriceValidate())->post()->goCheck('status');
        $result = LinePriceLogic::updateStatus($params);
        if (true === $result) {
            return $this->success('修改成功', [], 1, 1);
        }
        return $this->fail(LinePriceLogic::getError());
    }


}